package cn.itcast.day12.Calculate;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class CalculateBirthday {

    public static void main(String[] args) throws ParseException {

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你的生日，格式为yyyy-MM-dd");
        String BirthString = sc.next();
        //使用Dateformat类中的方法parse，把字符串的出生日期解析为Date格式
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date birthDate =  sdf.parse(BirthString);
        //将Date格式的出生日期转为毫秒值
        long birthTime = birthDate.getTime();
        //现在时间的毫秒值
        Long now = new Date().getTime();
        //作差
        long differ = now-birthTime;
        //算出天
        System.out.println(differ/1000/60/60/24);

    }
}
